package com.pipi.sso.web.shiro;

import com.pipi.sso.core.model.UserBO;
import com.pipi.sso.core.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.security.Security;
import java.util.List;

/**
 * All rights Reserved, Designed By www.maihaoche.com
 *
 * @Package com.pipi.sso.web.shiro
 * @date: 2019/4/15 3:29 PM
 * @Copyright: 2017-2020 www.maihaoche.com Inc. All rights reserved.
 */
@Service
public class UserInfoService {

    @Resource
    private UserService userService;

    public UserBO getCurrentUser() {
        String username = (String) SecurityUtils.getSubject().getSession().getAttribute("user");
        return userService.queryByUserName(username);
    }


    public void logout() {
        SecurityUtils.getSubject().getSession().stop();
    }
}
